﻿using Autofac;
using Autofac.Extras.DynamicProxy;
using Core.Infrastructures.Cores.Injections.Dependencies;
using Core.Infrastructures.Cores.Injections.Interceptors;
using System;
using System.Collections.Generic;
using System.Text;


namespace Core.Infrastructures.Cores.Injections.Modules
{
    public partial class ServiceModule:Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterAssemblyTypes(Initialize.ReferencedAssemblies).PublicOnly()
                .Where(type => !type.IsAbstract && typeof(IServiceDependency).IsAssignableFrom(type))
                .AsImplementedInterfaces()
                .EnableInterfaceInterceptors()
                .InterceptedBy(
                typeof(ProfilerInterceptor),
                //typeof(PurposeInterceptor),
                typeof(TransactionInterceptor))
                .InstancePerLifetimeScope();    // 注册所有实现IServiceDependency接口的服务对象，并基于请求创建
        }
    }
}
